var log = require('../../../log.js')

Page({
  data: {
    list: []
  },
  onLoad() {
    this.getList()
  },
  getList() {
    this.loadModal()
    //cloudfunction get
    wx.cloud.callFunction({
        name: 'getMySongList'
      })
      .then(res => {
        console.log(res.result.data)
        this.setData({
          list: res.result.data,
          loadModal: false,
        })
      })
      .catch(err => {
        this.setData({
          loadModal: false
        })
        log.error(err)
      })
  },
  //跳转详情页
  goDetail(e) {
    console.log('点击了跳转点歌详情', e.currentTarget.dataset.id)
    wx.navigateTo({
      url: '/pages/songListDetail/songListDetail?id=' + e.currentTarget.dataset.id
    })
  },
  loadModal() {
    this.setData({
      loadModal: true
    })
    var timerTem = setTimeout(() => {
      this.setData({
        loadModal: false
      })
    }, 700)
    var that = this
    that.setData({
      timer: timerTem
    })
  },
  onUnload() {
    console.log("+++++++++onUnload++++++++++")
    clearInterval(this.data.timer) //销毁定时器
  },
})